package com.totoro.service;

import org.hibernate.Criteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.totoro.dao.BaseHibernateDao;
import com.totoro.dao.ProjectDao;
import com.totoro.domain.Department;
import com.totoro.domain.Project;
import com.totoro.domain.Staff;
import com.totoro.domain.Student;
import com.totoro.domain.Tutor;
import com.totoro.util.Page;

/*
 * 毕业设计service
 */
@Transactional
@Service
public class ProjectService extends BaseService<Project, Integer>{

	private ProjectDao projectDao;
	
	@Autowired
	@Override
	public void setBaseDao(BaseHibernateDao<Project, Integer> projectDao) {
		// TODO Auto-generated method stub
		this.baseDao = projectDao;
		this.projectDao = (ProjectDao) projectDao;
	}
	
	
	//分页查询:通过页号、教研室
	public Page<Project> getPagePostsByDepartment(Integer pageNo,int pageSize,Department department){
		Criteria criteria = projectDao.createCriteria();
//		criteria.add(Restrictions.eq("department", department));
		criteria.addOrder(Order.asc("id"));
		return projectDao.pagedQuery(criteria, pageNo, pageSize);
	}
	
	

	
	//返回除turor之外，所有的毕业设计，供评阅人使用
	public Page<Project> getPagePostsByTutor(Integer pageNo,int pageSize,Tutor tutor){
		Criteria criteria = projectDao.createCriteria();
//		criteria.add(Restrictions.not(Restrictions.in("tutorial", tutor)));
		return projectDao.pagedQuery(criteria, pageNo, pageSize);
	}
	
}
